<script>
  import Emitter from '../../common/mixins/emitter';
  export default {
    name: 'at-checkbox-group',

    componentName: 'AtCheckboxGroup',

    mixins: [Emitter],

    props: {
      value: {},
      min: Number,
      max: Number,
      size: String,
      fill: String,
      textColor: String
    },

    watch: {
      value(value, oldVal) {
        this.dispatch('AtFormItem', 'at.form.change', [value]);
        if (value.length>oldVal.length){
          this.$emit('lastvalue', value[value.length-1]);
        }else if(value.length<oldVal.length){
          for (var i in oldVal){
            if (value.indexOf(oldVal[i])==-1){
              this.$emit('lastvalue', oldVal[i]);
            }
          }
        }
      }
    }
  };
</script>

<template>
  <div class="at-checkbox-group">
    <slot></slot>
  </div>
</template>
